package edu.hunau.cxb.reflect;

import java.lang.reflect.Constructor;
import java.lang.reflect.Field;
import java.lang.reflect.Method;

import org.junit.Test;

import edu.hunau.cxb.entiy.Moo;

/**
 *
 * @author hb
 *
 *         2020-04-28 15:18:11
 */
public class ClassInfoTest {

	@Test
	public void test01() {
		Class clazz = Moo.class;
		System.out.println("属性的信息");
		Field[] fields01 = clazz.getFields();
		for (Field field : fields01) {
			System.out.println(field);

		}
		System.out.println("获得所有的属性信息");
		Field[] declaredFields = clazz.getDeclaredFields();
		for (Field field : declaredFields) {
			System.out.println(field);
		}
	}
	
	@Test
	public void test02() {
		parseClass(String.class);
	}

	public void parseClass(Class clazz) {
		System.out.println("所有的属性");
		Field[] declaredFields = clazz.getDeclaredFields();
		for (Field field : declaredFields) {
			System.out.println(field);
		}
		
		System.out.println("\n\n所有的构造器");
		Constructor[] declaredConstructors = clazz.getDeclaredConstructors();
		for (Constructor constructor : declaredConstructors) {
			System.out.println(constructor);
		}
		
		System.out.println("\n\n所有的方法");
		 Method[] declaredMethods = clazz.getDeclaredMethods();
		 for (Method method : declaredMethods) {
			 System.out.println(method);
		}

	}
}
